package br.com.android;

import android.app.Activity;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.widget.Button;
import android.widget.Chronometer;

public class Cronometro extends Activity {

	 Chronometer mChronometer;

	    @Override
	    protected void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);

	        setContentView(R.layout.chronometer);

	        Button button;

	        mChronometer = (Chronometer) findViewById(R.id.chronometer);

	        // Watch for button clicks.
	        button = (Button) findViewById(R.id.start);
	        button.setOnClickListener(mStartListener);

	        button = (Button) findViewById(R.id.stop);
	        button.setOnClickListener(mStopListener);

	        button = (Button) findViewById(R.id.reset);
	        button.setOnClickListener(mResetListener);

	    }

	    View.OnClickListener mStartListener = new View.OnClickListener() {
			public void onClick(View v) {
				 mChronometer.start();
				
			}
		};

	    View.OnClickListener mStopListener = new View.OnClickListener() {
	        public void onClick(View v) {
	            mChronometer.stop();
	        }
	    };

	    View.OnClickListener mResetListener = new View.OnClickListener() {
	        public void onClick(View v) {
	            mChronometer.setBase(SystemClock.elapsedRealtime());
	        }
	    };

	    View.OnClickListener mSetFormatListener = new View.OnClickListener() {
	        public void onClick(View v) {
	            mChronometer.setFormat("Formatted time (%s)");
	        }
	    };

	    View.OnClickListener mClearFormatListener = new View.OnClickListener() {
	        public void onClick(View v) {
	            mChronometer.setFormat(null);
	        }
	    };
}
